package hk.ust.comp3111.ustnutrition.data.json;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class ApiResponseStatistics extends ApiResponseBase {
	double[] xs, ys;
	
	public void load(JSONObject obj) throws JSONException {
		super.load(obj);
		JSONArray ary = obj.getJSONArray("data");
		xs = new double[ary.length()];
		ys = new double[ary.length()];
		
		for(int i = 0; i < xs.length; i++) {
			xs[i] = ary.getJSONObject(i).getDouble("x");
			ys[i] = ary.getJSONObject(i).getDouble("y");
		}
	}
	
	public double getX(int i) {
		return xs[i];
	}
	
	public double getY(int i) {
		return ys[i];
	}
	
	public int getLength() {
		return xs.length;
	}
}


